import React,{Component} from 'react'
import PropTypes from 'prop-types'

class Men extends Component{
    render(){
        console.log('child-render')
        return (
                <div onClick={this.onclickfunc.bind(this)}>{this.props.test}</div>
        )
    }
    constructor(props){
        super(props)
        this.onclickfunc=this.onclickfunc.bind(this)
    }
    onclickfunc(e){
        console.log(this.props.index);
        if(typeof this.props.delete == "function" ){
            this.props.delete(this.props.index);
        }
        console.log(typeof this.props.delete);
    }
    componentWillReceiveProps(){
        console.log("传入子组件参数2222222222");
    }

    componentWillUnmount(){
        console.log("组件被删除")
    }
    shouldComponentUpdate(nextProps,nextState){
        if(nextProps.test !== this.props.test){
            return true;
        }else{
            return false;
        }
    }
}
Men.propTypes={
    test:PropTypes.string,
    delete:PropTypes.func,
    index:PropTypes.number.isRequired,
}
export default Men